﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:csla="clr-namespace:Csla.Wpf">

    <DataTemplate x:Key="BrokenRuleTemplate">
        <Grid>
            <Grid.Resources>
                <csla:BrokenRuleSeverityConverter x:Key="severityConverter" />
            </Grid.Resources>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Image Source="{Binding Severity, Converter={StaticResource severityConverter}}" Width="16" Height="16" Opacity="1" />
            <TextBlock Margin="5,2,2,2" Text="{Binding Description}" Grid.Column="1" />
        </Grid>
    </DataTemplate>

    <ControlTemplate x:Key="DefaultPopupTemplate">
        <ListBox ItemsSource="{Binding}" 
                 ItemTemplate="{StaticResource BrokenRuleTemplate}"
                 BorderThickness="{TemplateBinding BorderThickness}"
                 BorderBrush="{TemplateBinding BorderBrush}">
        </ListBox>
    </ControlTemplate>

    <Style TargetType="{x:Type csla:PropertyStatus}">
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Width" Value="16" />
        <Setter Property="Height" Value="16" />
        <Setter Property="PopupTemplate" Value="{StaticResource DefaultPopupTemplate}" />
        <Setter Property="BorderThickness" Value=".5" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type csla:PropertyStatus}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="Valid">
                            <DoubleAnimation Storyboard.TargetName="errorImage"
                                             Storyboard.TargetProperty="Opacity"
                                             BeginTime="00:00:00" Duration="0:0:1"
                                             To="0"/>
                            <DoubleAnimation Storyboard.TargetName="warningImage"
                                             Storyboard.TargetProperty="Opacity"
                                             BeginTime="00:00:00" Duration="0:0:1"
                                             To="0"/>
                            <DoubleAnimation Storyboard.TargetName="informationImage"
                                             Storyboard.TargetProperty="Opacity"
                                             BeginTime="00:00:00" Duration="0:0:1"
                                             To="0"/>

                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="errorImage" 
                                                           Storyboard.TargetProperty="Visibility"
                                                           Duration="00:00:0.1">
                                <DiscreteObjectKeyFrame KeyTime="00:00:0.1">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Hidden</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="warningImage" 
                                                           Storyboard.TargetProperty="Visibility"
                                                           Duration="00:00:0.1">
                                <DiscreteObjectKeyFrame KeyTime="00:00:0.1">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Hidden</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="informationImage" 
                                                           Storyboard.TargetProperty="Visibility"
                                                           Duration="00:00:0.1">
                                <DiscreteObjectKeyFrame KeyTime="00:00:0.1">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Hidden</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="Error">
                            <DoubleAnimation
	                                            Storyboard.TargetName="errorImage"
	                                            Storyboard.TargetProperty="Opacity"
	                                            BeginTime="00:00:00" Duration="0:0:1"
	                                            To="1"/>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="errorImage" 
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="Warning">
                            <DoubleAnimation
	                                            Storyboard.TargetName="warningImage"
	                                            Storyboard.TargetProperty="Opacity"
	                                            BeginTime="00:00:00" Duration="0:0:1"
	                                            To="1"/>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="warningImage" 
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="Information">
                            <DoubleAnimation
	                                            Storyboard.TargetName="informationImage"
	                                            Storyboard.TargetProperty="Opacity"
	                                            BeginTime="00:00:00" Duration="0:0:1"
	                                            To="1"/>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="informationImage" 
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid x:Name="root" 
                          Background="{TemplateBinding Background}"
                          Focusable="{TemplateBinding Focusable}">
                        <csla:BusyAnimation x:Name="busy"
                                            Focusable="{TemplateBinding Focusable}"
                                            IsRunning="{TemplateBinding IsBusy}"
                                            Foreground="{TemplateBinding Foreground}"
                                            Width="{TemplateBinding Width}" 
                                            Height="{TemplateBinding Height}" />
                        <Image x:Name="errorImage" 
                               Focusable="{TemplateBinding Focusable}"
                               Opacity="0"
                               Visibility="Collapsed"
                               Source="/Csla;component/Resources/Error.png"
                               Width="{TemplateBinding Width}" 
                               Height="{TemplateBinding Height}" />
                        <Image x:Name="warningImage" 
                               Focusable="{TemplateBinding Focusable}"
                               Opacity="0"
                               Visibility="Collapsed"
                               Source="/Csla;component/Resources/Warning.png"
                               Width="{TemplateBinding Width}" 
                               Height="{TemplateBinding Height}" />
                        <Image x:Name="informationImage" 
                               Focusable="{TemplateBinding Focusable}"
                               Opacity="0"
                               Visibility="Collapsed"
                               Source="/Csla;component/Resources/Information.png"
                               Width="{TemplateBinding Width}" 
                               Height="{TemplateBinding Height}" />
                        <Popup x:Name="popup">
                            <Control DataContext="{TemplateBinding BrokenRules}" 
                                     Template="{TemplateBinding PopupTemplate}"
                                     BorderThickness="{TemplateBinding BorderThickness}"
                                     BorderBrush="{TemplateBinding BorderBrush}" />
                        </Popup>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type csla:BusyAnimation}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Black" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Foreground" Value="Tan" />
        <Setter Property="StateDuration" Value="0:0:0.125" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type csla:BusyAnimation}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="normal">
                            <DoubleAnimation To="0"
                                             Duration="0"
                                             Storyboard.TargetName="part1"
                                             Storyboard.TargetProperty="Opacity" />
                            <DoubleAnimation To="0"
                                             Duration="0"
                                             Storyboard.TargetName="part2"
                                             Storyboard.TargetProperty="Opacity" />
                            <DoubleAnimation To="0"
                                             Duration="0"
                                             Storyboard.TargetName="part3"
                                             Storyboard.TargetProperty="Opacity" />
                            <DoubleAnimation To="0"
                                             Duration="0"
                                             Storyboard.TargetName="part4"
                                             Storyboard.TargetProperty="Opacity" />
                            <DoubleAnimation To="0"
                                             Duration="0"
                                             Storyboard.TargetName="part5"
                                             Storyboard.TargetProperty="Opacity" />
                            <DoubleAnimation To="0"
                                             Duration="0"
                                             Storyboard.TargetName="part6"
                                             Storyboard.TargetProperty="Opacity" />
                            <DoubleAnimation To="0"
                                             Duration="0"
                                             Storyboard.TargetName="part7"
                                             Storyboard.TargetProperty="Opacity" />
                            <DoubleAnimation To="0"
                                             Duration="0"
                                             Storyboard.TargetName="part8"
                                             Storyboard.TargetProperty="Opacity" />
                        </Storyboard>
                        <Storyboard x:Key="state1">
                            <DoubleAnimation Storyboard.TargetName="part5"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To="0" />
                            <DoubleAnimation Storyboard.TargetName="part6"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".25" />
                            <DoubleAnimation Storyboard.TargetName="part7"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".5" />
                            <DoubleAnimation Storyboard.TargetName="part8"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".75" />
                            <DoubleAnimation Storyboard.TargetName="part1"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To="1" />
                        </Storyboard>
                        <Storyboard x:Key="state2">
                            <DoubleAnimation Storyboard.TargetName="part6"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To="0" />
                            <DoubleAnimation Storyboard.TargetName="part7"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".25" />
                            <DoubleAnimation Storyboard.TargetName="part8"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".5" />
                            <DoubleAnimation Storyboard.TargetName="part1"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".75" />
                            <DoubleAnimation Storyboard.TargetName="part2"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To="1" />
                        </Storyboard>
                        <Storyboard x:Key="state3">
                            <DoubleAnimation Storyboard.TargetName="part7"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To="0" />
                            <DoubleAnimation Storyboard.TargetName="part8"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".25" />
                            <DoubleAnimation Storyboard.TargetName="part1"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".5" />
                            <DoubleAnimation Storyboard.TargetName="part2"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".75" />
                            <DoubleAnimation Storyboard.TargetName="part3"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To="1" />
                        </Storyboard>
                        <Storyboard x:Key="state4">
                            <DoubleAnimation Storyboard.TargetName="part8"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To="0" />
                            <DoubleAnimation Storyboard.TargetName="part1"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".25" />
                            <DoubleAnimation Storyboard.TargetName="part2"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".5" />
                            <DoubleAnimation Storyboard.TargetName="part3"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".75" />
                            <DoubleAnimation Storyboard.TargetName="part4"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To="1" />
                        </Storyboard>
                        <Storyboard x:Key="state5">
                            <DoubleAnimation Storyboard.TargetName="part1"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To="0" />
                            <DoubleAnimation Storyboard.TargetName="part2"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".25" />
                            <DoubleAnimation Storyboard.TargetName="part3"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".5" />
                            <DoubleAnimation Storyboard.TargetName="part4"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".75" />
                            <DoubleAnimation Storyboard.TargetName="part5"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To="1" />
                        </Storyboard>
                        <Storyboard x:Key="state6">
                            <DoubleAnimation Storyboard.TargetName="part2"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To="0" />
                            <DoubleAnimation Storyboard.TargetName="part3"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".25" />
                            <DoubleAnimation Storyboard.TargetName="part4"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".5" />
                            <DoubleAnimation Storyboard.TargetName="part5"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".75" />
                            <DoubleAnimation Storyboard.TargetName="part6"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To="1" />
                        </Storyboard>
                        <Storyboard x:Key="state7">
                            <DoubleAnimation Storyboard.TargetName="part3"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To="0" />
                            <DoubleAnimation Storyboard.TargetName="part4"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".25" />
                            <DoubleAnimation Storyboard.TargetName="part5"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".5" />
                            <DoubleAnimation Storyboard.TargetName="part6"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".75" />
                            <DoubleAnimation Storyboard.TargetName="part7"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To="1" />
                        </Storyboard>
                        <Storyboard x:Key="state8">
                            <DoubleAnimation Storyboard.TargetName="part4"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To="0" />
                            <DoubleAnimation Storyboard.TargetName="part5"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".25" />
                            <DoubleAnimation Storyboard.TargetName="part6"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".5" />
                            <DoubleAnimation Storyboard.TargetName="part7"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To=".75" />
                            <DoubleAnimation Storyboard.TargetName="part8"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0"
                                             To="1" />
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Canvas x:Name="root" Background="{TemplateBinding Background}" Visibility="{TemplateBinding Visibility}">
                        <Ellipse x:Name="part1" 
                                 Stroke="{TemplateBinding BorderBrush}"
                                 StrokeThickness="{TemplateBinding BorderThickness}"
                                 Fill="{TemplateBinding Foreground}"
                                 Opacity="0"
                                 Visibility="{TemplateBinding Visibility}"/>
                        <Ellipse x:Name="part2"
                                 Stroke="{TemplateBinding BorderBrush}"
                                 StrokeThickness="{TemplateBinding BorderThickness}"
                                 Fill="{TemplateBinding Foreground}"
                                 Opacity="0"
                                 Visibility="{TemplateBinding Visibility}"/>
                        <Ellipse x:Name="part3"
                                 Stroke="{TemplateBinding BorderBrush}"
                                 StrokeThickness="{TemplateBinding BorderThickness}"
                                 Fill="{TemplateBinding Foreground}"
                                 Opacity="0"
                                 Visibility="{TemplateBinding Visibility}"/>
                        <Ellipse x:Name="part4"
                                 Stroke="{TemplateBinding BorderBrush}"
                                 StrokeThickness="{TemplateBinding BorderThickness}"
                                 Fill="{TemplateBinding Foreground}"
                                 Opacity="0"
                                 Visibility="{TemplateBinding Visibility}"/>
                        <Ellipse x:Name="part5"
                                 Stroke="{TemplateBinding BorderBrush}"
                                 StrokeThickness="{TemplateBinding BorderThickness}"
                                 Fill="{TemplateBinding Foreground}"
                                 Opacity="0"
                                 Visibility="{TemplateBinding Visibility}"/>
                        <Ellipse x:Name="part6"
                                 Stroke="{TemplateBinding BorderBrush}"
                                 StrokeThickness="{TemplateBinding BorderThickness}"
                                 Fill="{TemplateBinding Foreground}"
                                 Opacity="0"
                                 Visibility="{TemplateBinding Visibility}"/>
                        <Ellipse x:Name="part7"
                                 Stroke="{TemplateBinding BorderBrush}"
                                 StrokeThickness="{TemplateBinding BorderThickness}"
                                 Fill="{TemplateBinding Foreground}"
                                 Opacity="0"
                                 Visibility="{TemplateBinding Visibility}"/>
                        <Ellipse x:Name="part8"
                                 Stroke="{TemplateBinding BorderBrush}"
                                 StrokeThickness="{TemplateBinding BorderThickness}"
                                 Fill="{TemplateBinding Foreground}"
                                 Opacity="0"
                                 Visibility="{TemplateBinding Visibility}"/>
                    </Canvas>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
